﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
using ExamRepositoryWPF.Models;

namespace ExamRepositoryWPF.Converters
{
    class QuestionTypeToTemplateConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            Type t = value?.GetType();
            try
            {
                if (t == typeof(EaseAnswerQuestion)) return App.Current.FindResource("easeQuestionDetailsContainer");
                if (t == typeof(JudgementQuestion)) return App.Current.FindResource("judgementQuestionDetailsContainer");
                if (t == typeof(SingleChoiceQuestion)) return App.Current.FindResource("singleChoiceQuestionDetailsContainer");
                if (t == typeof(MultiChoiceQuestion)) return App.Current.FindResource("multiChoiceQuestionDetailsContainer");
            }
            catch(Exception e)
            {
                return e.Message;
            }
            return null;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
